ins(X,Ys,.(X,Ys)).
ins(X,.(Y,Ys),.(Y,Zs)):-ins(X,Ys,Zs).

perm([],[]).
perm(.(X,Xs),Zs):-perm(Xs,Ys),ins(X,Ys,Zs).

g0(N):-range(0,N,Ns),perm(Ns,_),fail.
g0(_).

bm(N,T):-ctime(T1),g0(N),ctime(T2),dif(T2,T1,T).

bm(T):-bm(10,T).

go:-bm(T),println(T).

g1(N):-range(0,N,Ns),findall(Ps,perm(Ns,Ps),_),fail.
g1(_).

go1(N,T):-ctime(T1),g1(N),ctime(T2),dif(T2,T1,T).

go1:-go1(9,T),println(T).
